<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Flow-IPC: ipc::session::shm Namespace Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">Flow-IPC<span id="projectnumber">&#160;2.0.0</span>
   </div>
   <div id="projectbrief">Flow-IPC project: Full implementation reference.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceipc.html">ipc</a></li><li class="navelem"><a class="el" href="namespaceipc_1_1session.html">session</a></li><li class="navelem"><a class="el" href="namespaceipc_1_1session_1_1shm.html">shm</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#namespaces">Namespaces</a> &#124;
<a href="#nested-classes">Classes</a> &#124;
<a href="#typedef-members">Typedefs</a>  </div>
  <div class="headertitle"><div class="title">ipc::session::shm Namespace Reference</div></div>
</div><!--header-->
<div class="contents">

<p><a class="el" href="namespaceipc_1_1session.html" title="Flow-IPC module providing the broad lifecycle and shared-resource organization – via the session conc...">ipc::session</a> sub-namespace that groups together facilities for SHM-backed sessions, particularly augmenting <a class="el" href="namespaceipc_1_1session.html#a77d8fda00e1e17f595a6a5d4c44375e7" title="A vanilla Client_session with no optional capabilities.">Client_session</a>, <a class="el" href="namespaceipc_1_1session.html#ab01d5bce0ab2f3435ca9dd88d27609dc" title="A vanilla Server_session with no optional capabilities.">Server_session</a>, and <a class="el" href="classipc_1_1session_1_1Session__server.html" title="To be instantiated typically once in a given process, an object of this type asynchronously listens f...">Session_server</a> classes by providing SHM-backed zero-copy functionality.  
<a href="namespaceipc_1_1session_1_1shm.html#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
Namespaces</h2></td></tr>
<tr class="memitem:namespaceipc_1_1session_1_1shm_1_1arena__lend"><td class="memItemLeft" align="right" valign="top">namespace &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceipc_1_1session_1_1shm_1_1arena__lend.html">arena_lend</a></td></tr>
<tr class="memdesc:namespaceipc_1_1session_1_1shm_1_1arena__lend"><td class="mdescLeft">&#160;</td><td class="mdescRight">Bundles <a class="el" href="namespaceipc_1_1session_1_1shm.html" title="ipc::session sub-namespace that groups together facilities for SHM-backed sessions,...">ipc::session::shm</a> support for the various arena-lend-style SHM-providers, as of this writing at least <a class="el" href="namespaceipc_1_1session_1_1shm_1_1arena__lend_1_1jemalloc.html" title="Support for SHM-backed ipc::session sessions and session-servers with the SHM-jemalloc (ipc::shm::are...">ipc::session::shm::arena_lend::jemalloc</a>. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:namespaceipc_1_1session_1_1shm_1_1classic"><td class="memItemLeft" align="right" valign="top">namespace &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceipc_1_1session_1_1shm_1_1classic.html">classic</a></td></tr>
<tr class="memdesc:namespaceipc_1_1session_1_1shm_1_1classic"><td class="mdescLeft">&#160;</td><td class="mdescRight">Support for SHM-backed <a class="el" href="namespaceipc_1_1session.html" title="Flow-IPC module providing the broad lifecycle and shared-resource organization – via the session conc...">ipc::session</a> sessions and session-servers with the SHM-classic (<a class="el" href="classipc_1_1shm_1_1classic_1_1Pool__arena.html" title="A SHM-classic interface around a single SHM pool with allocation-algorithm services by boost....">ipc::shm::classic::Pool_arena</a>) provider. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structipc_1_1session_1_1shm_1_1Arena__to__shm__session.html">Arena_to_shm_session</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Implementation of <a class="el" href="namespaceipc_1_1session_1_1shm.html#af2acc444cc9664e57df8143b66b78d70" title="Alias that, given an Arena type (with Arena::construct&lt;T&gt;() which allocates/constructs a T),...">Arena_to_shm_session_t</a>.  <a href="structipc_1_1session_1_1shm_1_1Arena__to__shm__session.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structipc_1_1session_1_1shm_1_1Arena__to__shm__session_3_01ipc_1_1shm_1_1arena__lend_1_1jemalloc_1_1Ipc__arena_01_4.html">Arena_to_shm_session&lt; ipc::shm::arena_lend::jemalloc::Ipc_arena &gt;</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Implementation of <a class="el" href="namespaceipc_1_1session_1_1shm.html#af2acc444cc9664e57df8143b66b78d70" title="Alias that, given an Arena type (with Arena::construct&lt;T&gt;() which allocates/constructs a T),...">Arena_to_shm_session_t</a> for SHM-jemalloc arenas.  <a href="structipc_1_1session_1_1shm_1_1Arena__to__shm__session_3_01ipc_1_1shm_1_1arena__lend_1_1jemalloc_1_1Ipc__arena_01_4.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structipc_1_1session_1_1shm_1_1Arena__to__shm__session_3_01ipc_1_1shm_1_1classic_1_1Pool__arena_01_4.html">Arena_to_shm_session&lt; ipc::shm::classic::Pool_arena &gt;</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Implementation of <a class="el" href="namespaceipc_1_1session_1_1shm.html#af2acc444cc9664e57df8143b66b78d70" title="Alias that, given an Arena type (with Arena::construct&lt;T&gt;() which allocates/constructs a T),...">Arena_to_shm_session_t</a> for SHM-classic arenas.  <a href="structipc_1_1session_1_1shm_1_1Arena__to__shm__session_3_01ipc_1_1shm_1_1classic_1_1Pool__arena_01_4.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:af2acc444cc9664e57df8143b66b78d70"><td class="memTemplParams" colspan="2">template&lt;typename Arena &gt; </td></tr>
<tr class="memitem:af2acc444cc9664e57df8143b66b78d70"><td class="memTemplItemLeft" align="right" valign="top">using&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="namespaceipc_1_1session_1_1shm.html#af2acc444cc9664e57df8143b66b78d70">Arena_to_shm_session_t</a> = typename <a class="el" href="structipc_1_1session_1_1shm_1_1Arena__to__shm__session.html">Arena_to_shm_session</a>&lt; Arena &gt;::Type</td></tr>
<tr class="memdesc:af2acc444cc9664e57df8143b66b78d70"><td class="mdescLeft">&#160;</td><td class="mdescRight">Alias that, given an <code>Arena</code> type (with <code>Arena::construct&lt;T&gt;()</code> which allocates/constructs a <code>T</code>), yields a <code>Shm_session</code> type over which one can <code>Shm_session::lend_object&lt;T&gt;()</code> so-constructed objects.  <a href="namespaceipc_1_1session_1_1shm.html#af2acc444cc9664e57df8143b66b78d70">More...</a><br /></td></tr>
<tr class="separator:af2acc444cc9664e57df8143b66b78d70"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p ><a class="el" href="namespaceipc_1_1session.html" title="Flow-IPC module providing the broad lifecycle and shared-resource organization – via the session conc...">ipc::session</a> sub-namespace that groups together facilities for SHM-backed sessions, particularly augmenting <a class="el" href="namespaceipc_1_1session.html#a77d8fda00e1e17f595a6a5d4c44375e7" title="A vanilla Client_session with no optional capabilities.">Client_session</a>, <a class="el" href="namespaceipc_1_1session.html#ab01d5bce0ab2f3435ca9dd88d27609dc" title="A vanilla Server_session with no optional capabilities.">Server_session</a>, and <a class="el" href="classipc_1_1session_1_1Session__server.html" title="To be instantiated typically once in a given process, an object of this type asynchronously listens f...">Session_server</a> classes by providing SHM-backed zero-copy functionality. </p>
<p ><a class="el" href="namespaceipc_1_1session_1_1shm.html" title="ipc::session sub-namespace that groups together facilities for SHM-backed sessions,...">ipc::session::shm</a> is itself empty or almost empty; but for each possible SHM provider there is a further sub-namespace; for example <a class="el" href="namespaceipc_1_1session_1_1shm_1_1classic.html" title="Support for SHM-backed ipc::session sessions and session-servers with the SHM-classic (ipc::shm::clas...">ipc::session::shm::classic</a>.</p>
<h3>Background</h3>
<p ><a class="el" href="namespaceipc_1_1shm.html" title="Modules for SHared Memory (SHM) support.">ipc::shm</a> provides SHM facilities, including <a class="el" href="namespaceipc_1_1shm_1_1classic.html" title="ipc::shm sub-module with the SHM-classic SHM-provider. See ipc::shm doc header for introduction.">ipc::shm::classic</a> and ipc::shm::arena_lend::jemalloc, that can be used stand-alone, without <a class="el" href="namespaceipc_1_1session.html" title="Flow-IPC module providing the broad lifecycle and shared-resource organization – via the session conc...">ipc::session</a>. As with <a class="el" href="namespaceipc_1_1transport.html" title="Flow-IPC module providing transmission of structured messages and/or low-level blobs (and more) betwe...">ipc::transport</a>, though, this is not very convenient. <a class="el" href="namespaceipc_1_1session.html" title="Flow-IPC module providing the broad lifecycle and shared-resource organization – via the session conc...">ipc::session</a> is well integrated with <a class="el" href="namespaceipc_1_1shm.html" title="Modules for SHared Memory (SHM) support.">ipc::shm</a> in that it provides certain pre-made arenas and simplifies transmission of handles to SHM-constructed objects and allows to place <a class="el" href="classipc_1_1transport_1_1struc_1_1Channel.html" title="Owning and wrapping a pre-connected transport::Channel peer (an endpoint of an established channel ov...">transport::struc::Channel</a> out-messages into SHM instead of heap &ndash; achieving full zero-copy if desired. <a class="el" href="namespaceipc_1_1session_1_1shm.html" title="ipc::session sub-namespace that groups together facilities for SHM-backed sessions,...">ipc::session::shm</a> is where this support lives.</p>
<h3>Details</h3>
<p >If you want these features, everything in the "Overview of relevant APIs" section (of <a class="el" href="namespaceipc_1_1session.html" title="Flow-IPC module providing the broad lifecycle and shared-resource organization – via the session conc...">ipc::session</a> doc header) still applies identically, except you shall choose different types rather than <a class="el" href="namespaceipc_1_1session.html#a77d8fda00e1e17f595a6a5d4c44375e7" title="A vanilla Client_session with no optional capabilities.">Client_session</a>, <a class="el" href="namespaceipc_1_1session.html#ab01d5bce0ab2f3435ca9dd88d27609dc" title="A vanilla Server_session with no optional capabilities.">Server_session</a>, <a class="el" href="classipc_1_1session_1_1Session__server.html" title="To be instantiated typically once in a given process, an object of this type asynchronously listens f...">Session_server</a>. Firstly decide which SHM-provider; as of this writing <a class="el" href="classipc_1_1shm_1_1classic_1_1Pool__arena.html" title="A SHM-classic interface around a single SHM pool with allocation-algorithm services by boost....">ipc::shm::classic::Pool_arena</a> or ipc::shm::arena_lend::jemalloc. For illustration let's assume you chose the former. Then:</p><ul>
<li>Use <a class="el" href="namespaceipc_1_1session_1_1shm_1_1classic.html#ac6c443a72e0f22710c83bb1e8c229618" title="This is to session::Client_session what shm::classic::Server_session is to session::Server_session.">shm::classic::Client_session</a> in place of vanilla <a class="el" href="namespaceipc_1_1session.html#a77d8fda00e1e17f595a6a5d4c44375e7" title="A vanilla Client_session with no optional capabilities.">Client_session</a>.</li>
<li>Use <a class="el" href="classipc_1_1session_1_1shm_1_1classic_1_1Session__server.html" title="This is to vanilla Session_server what shm::classic::Server_session is to vanilla Server_session: it ...">shm::classic::Session_server</a> in place of vanilla <a class="el" href="classipc_1_1session_1_1Session__server.html" title="To be instantiated typically once in a given process, an object of this type asynchronously listens f...">Session_server</a>.<ul>
<li>This will emit <a class="el" href="classipc_1_1session_1_1shm_1_1classic_1_1Server__session.html" title="Identical to session::Server_session in every way, except that it makes available two SHM arenas,...">shm::classic::Server_session</a> in place of vanilla <a class="el" href="namespaceipc_1_1session.html#ab01d5bce0ab2f3435ca9dd88d27609dc" title="A vanilla Server_session with no optional capabilities.">Server_session</a>.</li>
</ul>
</li>
</ul>
<p >We strongly recommend making yourself aliases as shown below, then from that point on obtaining all subsequent <a class="el" href="namespaceipc_1_1session.html" title="Flow-IPC module providing the broad lifecycle and shared-resource organization – via the session conc...">ipc::session</a> types via aliases contained within those aliases (and then more aliases off those aliases as needed). The idea is to have only one point in the code where the SHM-backing (or no SHM backing) of the system are specified (simply by indicating the namespace of the top-level <code><a class="el" href="classipc_1_1session_1_1Session__server.html" title="To be instantiated typically once in a given process, an object of this type asynchronously listens f...">Session_server</a></code> or <code>Client_session</code> type of choice), so that it can be easily changed to another, a-la generic programming.</p>
<p >Server-side:</p>
<div class="fragment"><div class="line"><span class="keyword">using </span><a class="code hl_class" href="classipc_1_1session_1_1Session__server.html">Session_server</a> = <a class="code hl_class" href="classipc_1_1session_1_1shm_1_1classic_1_1Session__server.html">ipc::session::shm::classic::Session_server</a></div>
<div class="line">                         &lt;...&gt;; <span class="comment">// Compile-time session-configuring knobs go here.</span></div>
<div class="line"><span class="comment">// ^-- Substitute shm::arena_lend::jemalloc::Session_server or even non-zero-copy plain Session_server as desired.</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// From this point on, no need to mention `ipc::session` again.  In particular, e.g.:</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">using </span><a class="code hl_class" href="classipc_1_1session_1_1Session.html">Session</a> = <span class="keyword">typename</span> <a class="code hl_typedef" href="classipc_1_1session_1_1Session__server.html#a4140ba69205b68aec322ad834f4c8d59">Session_server::Server_session_obj</a>;</div>
<div class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> Message_body&gt;</div>
<div class="line"><span class="keyword">using </span>Structured_channel = <span class="keyword">typename</span> Session::template Structured_channel&lt;Message_body&gt;;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Off we go!  Use the types as needed.</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// ...</span></div>
<div class="line"><a class="code hl_class" href="classipc_1_1session_1_1Session.html">Session</a> session; <span class="comment">// Maybe fill it out with Session_server::async_accept() following this.</span></div>
<div class="line"><span class="comment">// ...</span></div>
<div class="line">Structured_channel&lt;MessageSchemaRootOfTheGods&gt; cool_channel(...);</div>
<div class="line"><span class="comment">// ...</span></div>
<div class="ttc" id="aclassipc_1_1session_1_1Session__server_html"><div class="ttname"><a href="classipc_1_1session_1_1Session__server.html">ipc::session::Session_server</a></div><div class="ttdoc">To be instantiated typically once in a given process, an object of this type asynchronously listens f...</div><div class="ttdef"><b>Definition:</b> <a href="ipc__session_2src_2ipc_2session_2session__server_8hpp_source.html#l00193">session_server.hpp:197</a></div></div>
<div class="ttc" id="aclassipc_1_1session_1_1Session__server_html_a4140ba69205b68aec322ad834f4c8d59"><div class="ttname"><a href="classipc_1_1session_1_1Session__server.html#a4140ba69205b68aec322ad834f4c8d59">ipc::session::Session_server::Server_session_obj</a></div><div class="ttdeci">Server_session&lt; S_MQ_TYPE_OR_NONE, S_TRANSMIT_NATIVE_HANDLES, Mdt_payload &gt; Server_session_obj</div><div class="ttdoc">Short-hand for the concrete Server_session-like type emitted by async_accept().</div><div class="ttdef"><b>Definition:</b> <a href="ipc__session_2src_2ipc_2session_2session__server_8hpp_source.html#l00210">session_server.hpp:210</a></div></div>
<div class="ttc" id="aclassipc_1_1session_1_1Session_html"><div class="ttname"><a href="classipc_1_1session_1_1Session.html">ipc::session::Session</a></div><div class="ttdoc">A documentation-only concept defining the local side of an IPC conversation (session) with another en...</div><div class="ttdef"><b>Definition:</b> <a href="ipc__session_2src_2ipc_2session_2session_8hpp_source.html#l00215">session.hpp:216</a></div></div>
<div class="ttc" id="aclassipc_1_1session_1_1shm_1_1classic_1_1Session__server_html"><div class="ttname"><a href="classipc_1_1session_1_1shm_1_1classic_1_1Session__server.html">ipc::session::shm::classic::Session_server</a></div><div class="ttdoc">This is to vanilla Session_server what shm::classic::Server_session is to vanilla Server_session: it ...</div><div class="ttdef"><b>Definition:</b> <a href="ipc__shm_2src_2ipc_2session_2shm_2classic_2session__server_8hpp_source.html#l00070">session_server.hpp:74</a></div></div>
</div><!-- fragment --><p >Client-side:</p>
<div class="fragment"><div class="line"><span class="keyword">using </span><a class="code hl_class" href="classipc_1_1session_1_1Session.html">Session</a> = <a class="code hl_class" href="classipc_1_1session_1_1shm_1_1classic_1_1Session__mv.html">ipc::session::shm::classic::Client_session</a></div>
<div class="line">                  &lt;...&gt;; <span class="comment">// Matching (to server-side) knobs go here.</span></div>
<div class="line"><span class="comment">// ^-- Substitute shm::arena_lend::jemalloc::Client_session or even non-zero-copy plain Client_session as desired.</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// From this point on, no need to mention `ipc::session` again.  In particular, e.g.:</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">using </span><a class="code hl_class" href="classipc_1_1session_1_1Session.html">Session</a> = <span class="keyword">typename</span> <a class="code hl_typedef" href="classipc_1_1session_1_1Session__server.html#a4140ba69205b68aec322ad834f4c8d59">Session_server::Server_session_obj</a>;</div>
<div class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> Message_body&gt;</div>
<div class="line"><span class="keyword">using </span>Structured_channel = <span class="keyword">typename</span> Session::template Structured_channel&lt;Message_body&gt;;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Off we go!  Use the types as needed.</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// ...</span></div>
<div class="line"><a class="code hl_class" href="classipc_1_1session_1_1Session.html">Session</a> session(...); <span class="comment">// Maybe .sync_connect() following this.</span></div>
<div class="line"><span class="comment">// ...</span></div>
<div class="line">Structured_channel&lt;MessageSchemaRootOfTheGods&gt; cool_channel(...);</div>
<div class="line"><span class="comment">// ...</span></div>
<div class="ttc" id="aclassipc_1_1session_1_1shm_1_1classic_1_1Session__mv_html"><div class="ttname"><a href="classipc_1_1session_1_1shm_1_1classic_1_1Session__mv.html">ipc::session::shm::classic::Session_mv</a></div><div class="ttdoc">Implements the SHM-related API common to shm::classic::Server_session and shm::classic::Client_sessio...</div><div class="ttdef"><b>Definition:</b> <a href="ipc__shm_2src_2ipc_2session_2shm_2classic_2session_8hpp_source.html#l00042">session.hpp:44</a></div></div>
</div><!-- fragment --><p >Entering PEER state is exactly identical to the vanilla APIs (the differences are under the hood). Once in PEER state, however, the added capabilities become available; these are on top of the <a class="el" href="classipc_1_1session_1_1Session.html" title="A documentation-only concept defining the local side of an IPC conversation (session) with another en...">Session</a> concept API, in the form added members including methods. A quick survey:</p><ul>
<li>Each of <a class="el" href="namespaceipc_1_1session_1_1shm_1_1classic.html#ac6c443a72e0f22710c83bb1e8c229618" title="This is to session::Client_session what shm::classic::Server_session is to session::Server_session.">shm::classic::Client_session</a> and <a class="el" href="classipc_1_1session_1_1shm_1_1classic_1_1Server__session.html" title="Identical to session::Server_session in every way, except that it makes available two SHM arenas,...">shm::classic::Server_session</a> is a <a class="el" href="classipc_1_1session_1_1shm_1_1classic_1_1Session__mv.html" title="Implements the SHM-related API common to shm::classic::Server_session and shm::classic::Client_sessio...">shm::classic::Session_mv</a> (alias and sub-class respectively). shm::classic::Session::session_shm() and shm::classic::Session::app_shm() each access the pre-made SHM arenas of the aforementioned scopes (per-session and per-app respectively). Call <code>construct&lt;T&gt;(...)</code> on either to SHM-construct an object. Use an STL-compliant <code>T</code> with <code>Session::Allocator</code> and <a class="el" href="classipc_1_1shm_1_1stl_1_1Arena__activator.html" title="RAII-style class operating a stack-like notion of a the given thread&#39;s currently active SHM-aware Are...">shm::stl::Arena_activator</a> aids to store sophisticated data structures in SHM. Use <a class="el" href="classipc_1_1session_1_1shm_1_1classic_1_1Session__mv.html#a794f83a8111428b3b1feec7216f692dd" title="Adds an owner process to the owner set of the given session_shm-&gt;construct()- or app_shm()-&gt;construct...">shm::classic::Session_mv::lend_object()</a> to prepare to transmit an outer SHM-handle to such a <code>T</code> to the opposing shm::classic::Session. On that side use <a class="el" href="classipc_1_1session_1_1shm_1_1classic_1_1Session__mv.html#a4223fc944735adb6946a9d1938d06a20" title="Completes the cross-process operation begun by oppsing Session_mv::lend_object() that returned serial...">shm::classic::Session_mv::borrow_object()</a> to recover an equivalent outer SHM-handle. The <code>T</code> shall be returned to the SHM-arena once <em>both</em> processes are done with it. The handle acts like a cross-process-GCing <code>shared_ptr</code> (and is, in fact, <code>shared_ptr&lt;T&gt;</code>).<ul>
<li>This enables manually-constructing structures and transmitting them from one session participant to the other.</li>
<li>On the borrower side one should define <code>T</code> in terms of <code>"Session::Borrower_allocator"</code> instead of <code>"Session::Allocator"</code>. (With SHM-classic they are the same type; but with arena-lending SHM providers, SHM-jemalloc at the moment, they are not.)</li>
</ul>
</li>
<li>Suppose you have opened a channel C between your two peer objects. Suppose you upgrade it to a <a class="el" href="classipc_1_1transport_1_1struc_1_1Channel.html" title="Owning and wrapping a pre-connected transport::Channel peer (an endpoint of an established channel ov...">transport::struc::Channel</a>. Without SHM, your only out-of-the-box choice for out-message serialization is the heap (<a class="el" href="structipc_1_1transport_1_1struc_1_1Channel__base_1_1Serialize__via__heap.html" title="Tag type for ctor selection: Backing memory for serialization comes from fixed-size segment allocatio...">transport::struc::Channel_base::Serialize_via_heap</a>-tag ctor). This involves copying into and out of the low-level IPC transport. With SHM you can now do better: as you mutate your out-message, it will be invisibly backed by SHM-allocated segment(s); and when you <code>send()</code> and receive it, only a small handle will be copied into and out of the IPC transport (again invisibly to you; it'll just happen). To set it up simply use <code><a class="el" href="structipc_1_1transport_1_1struc_1_1Channel__base_1_1Serialize__via__session__shm.html" title="Tag type for ctor selection: Backing RAM for serialization comes from a given session::Session&#39;s SHM ...">transport::struc::Channel_base::Serialize_via_session_shm</a></code>-tag (or possibly <code>Serialize_via_app_shm</code>-tag) ctor of <code>struc::Channel</code>.<ul>
<li>This enables zero-copy-enabled/arbitrarily-large structured messages through channels in your <a class="el" href="namespaceipc_1_1session_1_1shm_1_1classic.html#ac6c443a72e0f22710c83bb1e8c229618" title="This is to session::Client_session what shm::classic::Server_session is to session::Server_session.">shm::classic::Client_session</a>&lt;-&gt;<a class="el" href="classipc_1_1session_1_1shm_1_1classic_1_1Server__session.html" title="Identical to session::Server_session in every way, except that it makes available two SHM arenas,...">shm::classic::Server_session</a> session.</li>
</ul>
</li>
</ul>
<p >That's with SHM-classic. With SHM-jemalloc it is all quite similar; basically just replace <code>classic</code> with <code><a class="el" href="namespaceipc_1_1session_1_1shm_1_1arena__lend_1_1jemalloc.html" title="Support for SHM-backed ipc::session sessions and session-servers with the SHM-jemalloc (ipc::shm::are...">arena_lend::jemalloc</a></code> in various names above (more or less). Reminder: it is easiest and most stylish to not have to a big search/replace but rather to use the top-level alias technique shown in the above code snippets.</p>
<p >Further details about SHM-classic versus SHM-jemalloc (etc.) are documented elsewhere. Preview: <code><a class="el" href="namespaceipc_1_1session_1_1shm_1_1arena__lend_1_1jemalloc.html" title="Support for SHM-backed ipc::session sessions and session-servers with the SHM-jemalloc (ipc::shm::are...">arena_lend::jemalloc</a></code> is safer and faster (backed by the commercial-grade "jemalloc" <code>malloc()</code> impl algorithm), though it does not allow <code>app_shm()-&gt;construct()</code> (per-app-scope allocation) on the client side (via <a class="el" href="namespaceipc_1_1session_1_1shm_1_1arena__lend_1_1jemalloc.html#a837b4566cb2a734eb0ba58f285d084fe" title="This is to session::Client_session what shm::arena_lend::jemalloc::Server_session is to session::Serv...">shm::arena_lend::jemalloc::Client_session</a> &ndash; available only <a class="el" href="classipc_1_1session_1_1shm_1_1arena__lend_1_1jemalloc_1_1Server__session.html" title="Identical to session::Server_session in every way, except that it makes available two SHM arenas,...">shm::arena_lend::jemalloc::Server_session</a>); there's no such method as <code>shm::arena_lend::jemalloc::Client_session::app_shm()</code>.</p>
<h3>One more small thing: logging addendum for SHM-jemalloc users</h3>
<p >This is really a footnote in importance, though there's no good reason to ignore it either. A certain aspect of SHM-jemalloc (and potentially more future arena-lending-type SHM-providers) requires singleton-based (essentially, global) operation. You need not worry about it... it just works... except it (like all Flow-IPC code) logs; and thus needs to know to which <code>Logger</code> to log. Since various <a class="el" href="namespaceipc_1_1session.html" title="Flow-IPC module providing the broad lifecycle and shared-resource organization – via the session conc...">ipc::session</a> objects don't want to presume whose <code>Logger</code> is the one to impose on this shared global guy &ndash; plus the setter is not thread-safe &ndash; we ask that you do so sometime before any ipc::session::arena_lend object creation. Namely just do this:</p>
<div class="fragment"><div class="line">ipc::session::shm::arena_lend::Borrower_shm_pool_collection_repository_singleton::get_instance()</div>
<div class="line">  .set_logger(...); <span class="comment">// ... = pointer to your Logger of choice.  Null to disable logging (which is default anyway).</span></div>
</div><!-- fragment --><p >If SHM-jemalloc is not used, this call is harmless. </p>
</div><h2 class="groupheader">Typedef Documentation</h2>
<a id="af2acc444cc9664e57df8143b66b78d70" name="af2acc444cc9664e57df8143b66b78d70"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af2acc444cc9664e57df8143b66b78d70">&#9670;&nbsp;</a></span>Arena_to_shm_session_t</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Arena &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">using <a class="el" href="namespaceipc_1_1session_1_1shm.html#af2acc444cc9664e57df8143b66b78d70">ipc::session::shm::Arena_to_shm_session_t</a> = typedef typename <a class="el" href="structipc_1_1session_1_1shm_1_1Arena__to__shm__session.html">Arena_to_shm_session</a>&lt;Arena&gt;::Type</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Alias that, given an <code>Arena</code> type (with <code>Arena::construct&lt;T&gt;()</code> which allocates/constructs a <code>T</code>), yields a <code>Shm_session</code> type over which one can <code>Shm_session::lend_object&lt;T&gt;()</code> so-constructed objects. </p>
<p >Informally, for informational convenience:</p><ul>
<li>Arena-sharing SHM-providers (classic::Pool_arena as of this writing), by definition, are symmetric, where each side can both lend and borrow, allocate and write within the same <code>Arena</code>. Hence they will map <code>Arena</code> to itself. The <code>Arena</code> object also acts as the <code>Shm_session</code>.</li>
<li>Arena-lending SHM-providers (<a class="el" href="namespaceipc_1_1session_1_1shm_1_1arena__lend_1_1jemalloc.html" title="Support for SHM-backed ipc::session sessions and session-servers with the SHM-jemalloc (ipc::shm::are...">arena_lend::jemalloc</a> as of this writing), by definition, are asymmetric; the borrowing side can only read, not allocate. Hence they will map <code>Arena</code> to a different dedicated <code>Shm_session</code> type.</li>
</ul>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">Arena</td><td>SHM arena type that has method of the form <code>shared_ptr&lt;T&gt; construct&lt;T&gt;(...)</code>. </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="session_2shm_2shm_8hpp_source.html#l00054">54</a> of file <a class="el" href="session_2shm_2shm_8hpp_source.html">shm.hpp</a>.</p>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 11 2025 20:02:26 for Flow-IPC by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
</small></address>
</body>
</html>
